<template>
  <view>
    <navbar/>
    <u-cell-group :border="false">
      <u-cell title="标题" :value="temp.title" :border="false"/>
      <system-user-cell title="用户" :model-value="temp.userId"/>
      <system-organization-cell title="部门" :model-value="temp.organizationId"/>
      <u-cell title="时间" :value="parseTime(temp.date, '{y}-{m}-{d}')" :border="false"/>
      <u-cell title="内容" :value="temp.content" :border="false"/>
      <image-gallery title="图片" :model-value="temp.image" :border="false"/>
    </u-cell-group>
    <u-button class="submit-button" type="primary" shape="circle" plain @click="edit">编辑</u-button>
  </view>
</template>

<script>
import { getEventDetail } from '@/api/event/event'
import SystemUserCell from '@/components/System/systemUserCell.vue'
import SystemOrganizationCell from '@/components/System/systemOrganizationCell.vue'
import ImageGallery from '@/components/ImageGallery/imageGallery.vue'
import Navbar from '@/components/Navbar/navbar.vue'

export default {
  components: { Navbar, ImageGallery, SystemOrganizationCell, SystemUserCell },
  data() {
    return {
      temp: {},
      show: false
    }
  },
  onLoad(query) {
    this.temp.id = query.id
    if (this.temp.id) {
      this.getDetail(query.id)
    }
  },
  methods: {
    // 获取详情
    getDetail(id) {
      getEventDetail(id).then(response => {
        if (response.data.success) {
          this.temp = response.data.data
        } else {
          this.$u.toast(response.data.message)
        }
      })
    },
    // 编辑
    edit() {
      uni.navigateTo({
        url: `/pages/event/eventForm?id=${this.temp.id}`
      })
    }
  }
}
</script>
